package com.tvt.sexyapp_demo.fragment.dialog;

import com.tvt.sexyapp_demo.R;
import com.tvt.sexyapp_demo.appconfig.reader.AppConfigReader;
import com.tvt.sexyapp_demo.sms.SmsSender;

import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class AppInfoDialog extends DialogFragment {

	private static final String APP_INFO_TITLE = "Thông tin ứng dụng";

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		View view = this.getAppInfoConfirm(inflater);
		getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
		getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
		getDialog().setCanceledOnTouchOutside(false);

		TextView txtPopupTitle = (TextView) view.findViewById(R.id.txtPopupTitle);
		txtPopupTitle.setText(APP_INFO_TITLE);

		TextView txtPopupContent = (TextView) view.findViewById(R.id.txtPopupContent);
		txtPopupContent.setText(AppConfigReader.getAppInfo(getActivity()));

		this.registerEventHandler(view);
		return view;
	}

	private View getAppInfoConfirm(LayoutInflater pInflater) {
		View view = pInflater.inflate(R.layout.appinfo_dialog, null);
		return view;
	}

	private void registerEventHandler(View pView) {

		Button btnOK = (Button) pView.findViewById(R.id.btnPopupOk);
		btnOK.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				AppInfoDialog.this.dismiss();
			}
		});

	}
}
